package CtrlLayer;

import java.io.IOException;
import java.util.List;
import ModelLayer.ItemContainer;
import ModelLayer.RentItem;
import ModelLayer.SaleItem;

public class ItemCtrl
{
	private ItemContainer IC;

	public ItemCtrl()
	{
		IC = ItemContainer.getInstance();
	}

	public void loadFromFile() throws IOException,ClassNotFoundException
	{
		IC.loadFromFile();
	}

	public void saveToFile() throws IOException
	{
		IC.saveToFile();
	}

	public void createSaleItem(int itemnr, String description, double price,
			int inStock, String location, String barCode, int minAmount, int maxAmount)
	{
		SaleItem mySaleItem = new SaleItem(itemnr,description,price,inStock,
				location,barCode,minAmount,maxAmount);
		IC.addSaleItem(mySaleItem);
	}

	public void createRentItem(int itemnr, String description, double price,
			int inStock, String location, String serialnr, boolean rented)
	{
		RentItem myRentItem = new RentItem(itemnr,description,price,inStock,
				location,serialnr,rented);
		IC.addRentItem(myRentItem);
	}

	public SaleItem searchSaleItem(int itemnr)
	{
		return IC.getSaleItem(itemnr);
	}

	public RentItem searchRentItem(int itemnr)
	{
		return IC.getRentItem(itemnr);
	}

	public List<SaleItem> getSaleItemList()
	{
		return IC.getSaleItemList();
	}
}
